//
//  BMSAuthManager.m
//  WDBMS
//
//  Created by YeJary on 2025/5/12.
//

#import "BMSAuthManager.h"
#import "BMSPrivacyPopupView.h"
#import "BMSPopupQueueManager.h"
#import "BMSRealnamePopupView.h"
#import "BMSPrivacyExitView.h"

@interface BMSAuthManager()


@end

@implementation BMSAuthManager

/// 触发隐私弹窗，回调用户是否同意
- (void)showPrivacyPopupWithCompletion:(void (^)(BOOL agreed))completion {
    BMSPrivacyPopupView *popup = [[BMSPrivacyPopupView alloc] init];
    popup.completion = ^(BOOL agreed) {
        [[BMSPopupQueueManager sharedManager] dismissCurrentPopup];
        if (completion) {
            completion(agreed); // ✅ 结果回传
        }
    };
    [[BMSPopupQueueManager sharedManager] presentPopup:popup];
}
- (void)showRealnamePopupWithCompletion:(void(^)(BOOL success))completion {
    BMSRealnamePopupView *popup = [[BMSRealnamePopupView alloc] init];
    
    popup.onResult = ^(BOOL success, NSError *error) {
        // 关闭弹窗
        [[BMSPopupQueueManager sharedManager] dismissCurrentPopup];
        
        // 回调结果
        if (completion) {
            completion(success);
        }
    };

    [[BMSPopupQueueManager sharedManager] presentPopup:popup];
}

- (void)showExitPopupWithCompletion:(void (^)(BOOL agreed))completion {
    BMSPrivacyExitView *popup = [[BMSPrivacyExitView alloc] init];
    popup.completion = ^(BOOL agreed) {
        [[BMSPopupQueueManager sharedManager] dismissCurrentPopup];
        if (completion) {
            completion(agreed); // ✅ 结果回传
        }
    };
    [[BMSPopupQueueManager sharedManager] presentPopup:popup];
}

@end
